package com.nexgo.payment.entity;

import android.os.Parcel;
import android.os.Parcelable;

import com.nexgo.payment.constrant.CardMode;
import com.nexgo.payment.constrant.OfflineState;
import com.nexgo.payment.constrant.SysConstant;
import com.nexgo.payment.constrant.TransType;

/**
 * Created by xiaox on 2017/2/7.
 */
public class TransData implements Parcelable {
    /**
     * 交易类型
     */
    private TransType transType;
    /**
     * 货币代码
     */
    private String fundType = SysConstant.FUND_CODE;
    /**
     * 12位金额
     */
    private String amount;
    /**
     * 输入方式码
     */
    private String entryMode;
    /**
     * 付款凭证码（扫码）
     */
    private String traceCode;
    /**
     * emv交易数据
     */
    private String field55Tlv;
    /**
     * 脚本数据
     */
    private String scriptTlv;
    /**
     * 冲正emv数据
     */
    private String reversalTlv;
    /**
     * 交易成功emv数据，用于打单等
     */
    private String resultTlv;
    /**
     * 交易脱机状态，脱机成功或是脱机拒绝
     */
    private OfflineState offlineState = OfflineState.ONLINE;
    /**
     * 交易是否arpc错
     */
    private boolean isArpcErr;
    /**
     * 交易是否交易成功
     */
    private boolean isSuccess;
    /**
     * 交易是否走了qps免密
     */
    private boolean isQpsFreePin;
    /**
     * 交易是否走了CDCVM免密免签
     */
    private boolean isCdcvm;
    /**
     * 交易是否走了免签
     */
    private boolean isQpsFreeSignature;
    /**
     * 交易是否fallback
     */
    private boolean isFallback;
    /**
     * 联机pin密文
     */
    private byte[] pin;
    /**
     * 卡号
     */
    private String pan;
    /**
     * 支付码号(扫码相关)
     */
    private String payCodeNo;
    /**
     * 卡序列号
     */
    private String csn;
    /**
     * 磁道数据
     */
    private String tk1, tk2, tk3;
    /**
     * 卡片有效期
     */
    private String expDate;
    /**
     * 卡片服务码
     */
    private String serviceCode;
    /**
     * 用卡方式
     */
    private CardMode cardMode;
    /**
     * 计数器
     */
    private int counter;
    /**
     * 临时存放
     */
    private String temporary;
    /**
     * 原交易流水号
     */
    private String orgTraceNum;
    /**
     * 原交易授权码
     */
    private String orgAuthCode;
    /**
     * 原系统参考号
     */
    private String orgRefNum;
    /**
     * 原交易批次号
     */
    private String orgBatchNum;
    /**
     * 原交易日期
     */
    private String orgDate;
    /**
     * 冲正原因码
     */
    private String reversalCode;
    /**
     * 是否非接强制输pin
     */
    private boolean isForcePin;
    /**
     * 是否信用卡
     */
    private boolean isCreditCard;

//   wzp add
//    wzp add 交行31域 免密标识 移动支付标识
    private String payMark;

    private String scanChannel;

    private Boolean isAutoQuery;

//    private String longitude;  //经度
//    private String  latitude;    //纬度




    public TransType getTransType() {
        return transType;
    }

    public void setTransType(TransType transType) {
        this.transType = transType;
    }

    public String getFundType() {
        return fundType;
    }

    public void setFundType(String fundType) {
        this.fundType = fundType;
    }

    public String getAmount() {
        return amount;
    }

    public void setAmount(String amount) {
        this.amount = amount;
    }

    public String getEntryMode() {
        return entryMode;
    }

    public void setEntryMode(String entryMode) {
        this.entryMode = entryMode;
    }

    public String getTraceCode() {
        return traceCode;
    }

    public void setTraceCode(String traceCode) {
        this.traceCode = traceCode;
    }

    public String getField55Tlv() {
        return field55Tlv;
    }

    public void setField55Tlv(String field55Tlv) {
        this.field55Tlv = field55Tlv;
    }

    public String getScriptTlv() {
        return scriptTlv;
    }

    public void setScriptTlv(String scriptTlv) {
        this.scriptTlv = scriptTlv;
    }

    public String getReversalTlv() {
        return reversalTlv;
    }

    public void setReversalTlv(String reversalTlv) {
        this.reversalTlv = reversalTlv;
    }

    public String getResultTlv() {
        return resultTlv;
    }

    public void setResultTlv(String resultTlv) {
        this.resultTlv = resultTlv;
    }

    public OfflineState getOfflineState() {
        return offlineState;
    }

    public void setOfflineState(OfflineState offlineState) {
        this.offlineState = offlineState;
    }

    public boolean isArpcErr() {
        return isArpcErr;
    }

    public void setArpcErr(boolean arpcErr) {
        isArpcErr = arpcErr;
    }

    public boolean isSuccess() {
        return isSuccess;
    }

    public void setSuccess(boolean success) {
        isSuccess = success;
    }

    public boolean isQpsFreePin() {
        return isQpsFreePin;
    }

    public void setQpsFreePin(boolean qpsFreePin) {
        isQpsFreePin = qpsFreePin;
    }

    public boolean isCdcvm() {
        return isCdcvm;
    }

    public void setCdcvm(boolean cdcvm) {
        isCdcvm = cdcvm;
    }

    public boolean isQpsFreeSignature() {
        return isQpsFreeSignature;
    }

    public void setQpsFreeSignature(boolean qpsFreeSignature) {
        isQpsFreeSignature = qpsFreeSignature;
    }

    public boolean isFallback() {
        return isFallback;
    }

    public void setFallback(boolean fallback) {
        isFallback = fallback;
    }

    public byte[] getPin() {
        return pin;
    }

    public void setPin(byte[] pin) {
        this.pin = pin;
    }

    public String getPan() {
        return pan;
    }

    public void setPan(String pan) {
        this.pan = pan;
    }

    public String getPayCodeNo() {
        return payCodeNo;
    }

    public void setPayCodeNo(String payCodeNo) {
        this.payCodeNo = payCodeNo;
    }

    public String getCsn() {
        return csn;
    }

    public void setCsn(String csn) {
        this.csn = csn;
    }

    public String getTk1() {
        return tk1;
    }

    public void setTk1(String tk1) {
        this.tk1 = tk1;
    }

    public String getTk2() {
        return tk2;
    }

    public void setTk2(String tk2) {
        this.tk2 = tk2;
    }

    public String getTk3() {
        return tk3;
    }

    public void setTk3(String tk3) {
        this.tk3 = tk3;
    }

    public String getExpDate() {
        return expDate;
    }

    public void setExpDate(String expDate) {
        this.expDate = expDate;
    }

    public String getServiceCode() {
        return serviceCode;
    }

    public void setServiceCode(String serviceCode) {
        this.serviceCode = serviceCode;
    }

    public CardMode getCardMode() {
        return cardMode;
    }

    public void setCardMode(CardMode cardMode) {
        this.cardMode = cardMode;
    }

    public int getCounter() {
        return counter;
    }

    public void setCounter(int counter) {
        this.counter = counter;
    }

    public String getTemporary() {
        return temporary;
    }

    public void setTemporary(String temporary) {
        this.temporary = temporary;
    }

    public String getOrgTraceNum() {
        return orgTraceNum;
    }

    public void setOrgTraceNum(String orgTraceNum) {
        this.orgTraceNum = orgTraceNum;
    }

    public String getOrgAuthCode() {
        return orgAuthCode;
    }

    public void setOrgAuthCode(String orgAuthCode) {
        this.orgAuthCode = orgAuthCode;
    }

    public String getOrgRefNum() {
        return orgRefNum;
    }

    public void setOrgRefNum(String orgRefNum) {
        this.orgRefNum = orgRefNum;
    }

    public String getOrgBatchNum() {
        return orgBatchNum;
    }

    public void setOrgBatchNum(String orgBatchNum) {
        this.orgBatchNum = orgBatchNum;
    }

    public String getOrgDate() {
        return orgDate;
    }

    public void setOrgDate(String orgDate) {
        this.orgDate = orgDate;
    }

    public String getReversalCode() {
        return reversalCode;
    }

    public void setReversalCode(String reversalCode) {
        this.reversalCode = reversalCode;
    }

    public boolean isForcePin() {
        return isForcePin;
    }

    public void setForcePin(boolean forcePin) {
        isForcePin = forcePin;
    }

    public boolean isCreditCard() {
        return isCreditCard;
    }

    public void setCreditCard(boolean creditCard) {
        isCreditCard = creditCard;
    }

    public String getPayMark() {
        return payMark;
    }

    public void setPayMark(String payMark) {
        this.payMark = payMark;
    }
	  public String getScanChannel() {
        return scanChannel;
    }

    public void setScanChannel(String scanChannel) {
        this.scanChannel = scanChannel;
    }

    public Boolean getIsAutoQuery() {
        return isAutoQuery;
    }

    public void setIsAutoQuery(Boolean isAutoQuery) {
        this.isAutoQuery = isAutoQuery;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.transType == null ? -1 : this.transType.ordinal());
        dest.writeString(this.fundType);
        dest.writeString(this.amount);
        dest.writeString(this.entryMode);
        dest.writeString(this.traceCode);
        dest.writeString(this.field55Tlv);
        dest.writeString(this.scriptTlv);
        dest.writeString(this.reversalTlv);
        dest.writeString(this.resultTlv);
        dest.writeInt(this.offlineState == null ? -1 : this.offlineState.ordinal());
        dest.writeByte(this.isArpcErr ? (byte) 1 : (byte) 0);
        dest.writeByte(this.isSuccess ? (byte) 1 : (byte) 0);
        dest.writeByte(this.isQpsFreePin ? (byte) 1 : (byte) 0);
        dest.writeByte(this.isCdcvm ? (byte) 1 : (byte) 0);
        dest.writeByte(this.isQpsFreeSignature ? (byte) 1 : (byte) 0);
        dest.writeByte(this.isFallback ? (byte) 1 : (byte) 0);
        dest.writeByteArray(this.pin);
        dest.writeString(this.pan);
        dest.writeString(this.payCodeNo);
        dest.writeString(this.csn);
        dest.writeString(this.tk1);
        dest.writeString(this.tk2);
        dest.writeString(this.tk3);
        dest.writeString(this.expDate);
        dest.writeString(this.serviceCode);
        dest.writeInt(this.cardMode == null ? -1 : this.cardMode.ordinal());
        dest.writeInt(this.counter);
        dest.writeString(this.temporary);
        dest.writeString(this.orgTraceNum);
        dest.writeString(this.orgAuthCode);
        dest.writeString(this.orgRefNum);
        dest.writeString(this.orgBatchNum);
        dest.writeString(this.orgDate);
        dest.writeString(this.reversalCode);
        dest.writeByte(this.isForcePin ? (byte) 1 : (byte) 0);
        dest.writeByte(this.isCreditCard ? (byte) 1 : (byte) 0);
     	dest.writeString(this.payMark);  //wzp add
        dest.writeString(this.scanChannel);
    }

    public TransData() {
    }

    protected TransData(Parcel in) {
        int tmpTransType = in.readInt();
        this.transType = tmpTransType == -1 ? null : TransType.values()[tmpTransType];
        this.fundType = in.readString();
        this.amount = in.readString();
        this.entryMode = in.readString();
        this.traceCode = in.readString();
        this.field55Tlv = in.readString();
        this.scriptTlv = in.readString();
        this.reversalTlv = in.readString();
        this.resultTlv = in.readString();
        int tmpOfflineState = in.readInt();
        this.offlineState = tmpOfflineState == -1 ? null : OfflineState.values()[tmpOfflineState];
        this.isArpcErr = in.readByte() != 0;
        this.isSuccess = in.readByte() != 0;
        this.isQpsFreePin = in.readByte() != 0;
        this.isCdcvm = in.readByte() != 0;
        this.isQpsFreeSignature = in.readByte() != 0;
        this.isFallback = in.readByte() != 0;
        this.pin = in.createByteArray();
        this.pan = in.readString();
        this.payCodeNo = in.readString();
        this.csn = in.readString();
        this.tk1 = in.readString();
        this.tk2 = in.readString();
        this.tk3 = in.readString();
        this.expDate = in.readString();
        this.serviceCode = in.readString();
        int tmpCardMode = in.readInt();
        this.cardMode = tmpCardMode == -1 ? null : CardMode.values()[tmpCardMode];
        this.counter = in.readInt();
        this.temporary = in.readString();
        this.orgTraceNum = in.readString();
        this.orgAuthCode = in.readString();
        this.orgRefNum = in.readString();
        this.orgBatchNum = in.readString();
        this.orgDate = in.readString();
        this.reversalCode = in.readString();
        this.isForcePin = in.readByte() != 0;
        this.isCreditCard = in.readByte() != 0;
  		this.payMark = in.readString();
        this.scanChannel = in.readString();
    }

    public static final Creator<TransData> CREATOR = new Creator<TransData>() {
        @Override
        public TransData createFromParcel(Parcel source) {
            return new TransData(source);
        }

        @Override
        public TransData[] newArray(int size) {
            return new TransData[size];
        }
    };

}
